<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4">
<head>
    <title>Hello World!</title>
</head>
<body>
<h1 th:inline="text">Hello [[${#httpServletRequest.remoteUser}]]!</h1>

<div sec:authorize="isAuthenticated()">
    <p>已有用户登录</p>
    <p>登录的用户为: <span sec:authentication="name"></span></p>
    <p>用户角色为: <span sec:authentication="principal.authorities"></span></p>
</div>
<p><a href="/admin/hello">跳转到管理员页面</a></p>
<p><a href="/user/hello">跳转到普通用户页面</a></p>
<form th:action="@{/logout}" method="post">
    <input type="submit" value="注销"/>
</form>
</body>
</html>